Skip to content

Conversation

akiramenai
Copy link
Collaborator

@akiramenai akiramenai commented Jul 30, 2025

  • Reimplement conditional jump optimization as a peephole pass
  • Extend the transformation to partially support OR in predicates

@akiramenai akiramenai marked this pull request as draft July 30, 2025 09:32
Copy link

github-actions bot commented Jul 30, 2025

Results for: evm ir-llvm EVMInterpreter
╔═╡ Size (-%) ╞═══════════════════════╡ All E +M3B3 ╞═╗
║ Best                                          0.478 ║
║ Worst                                         0.000 ║
║ Total                                         0.001 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All E +M3B3 ╞═╣
║ Best                                          2.056 ║
║ Worst                                        -0.182 ║
║ Total                                         0.000 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All E +M3B3 ╞═╣
║ Best                                          3.345 ║
║ Worst                                        -0.020 ║
║ Total                                         0.000 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All E +M3B3 ╞═╣
║ Best                                          0.904 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═══════════════════════╡ All E +MzB3 ╞═╗
║ Best                                          0.485 ║
║ Worst                                         0.000 ║
║ Total                                         0.001 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All E +MzB3 ╞═╣
║ Best                                          1.309 ║
║ Worst                                         0.000 ║
║ Total                                         0.001 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All E +MzB3 ╞═╣
║ Best                                          0.909 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All E +MzB3 ╞═╣
║ Best                                          0.984 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═══════════════════════╡ All Y +M3B3 ╞═╗
║ Best                                          4.812 ║
║ Worst                                         0.000 ║
║ Total                                         0.965 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All Y +M3B3 ╞═╣
║ Best                                          3.810 ║
║ Worst                                        -0.211 ║
║ Total                                         0.029 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All Y +M3B3 ╞═╣
║ Best                                          3.359 ║
║ Worst                                        -0.026 ║
║ Total                                         0.050 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All Y +M3B3 ╞═╣
║ Best                                          6.061 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═══════════════════════╡ All Y +MzB3 ╞═╗
║ Best                                          4.029 ║
║ Worst                                         0.000 ║
║ Total                                         0.950 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All Y +MzB3 ╞═╣
║ Best                                          3.810 ║
║ Worst                                        -0.211 ║
║ Total                                         0.025 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All Y +MzB3 ╞═╣
║ Best                                          3.359 ║
║ Worst                                        -0.026 ║
║ Total                                         0.036 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All Y +MzB3 ╞═╣
║ Best                                          6.061 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life E +M3B3 ╞═╗
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life E +M3B3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life E +M3B3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life E +M3B3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life E +MzB3 ╞═╗
║ Best                                          0.019 ║
║ Worst                                         0.000 ║
║ Total                                         0.004 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life E +MzB3 ╞═╣
║ Best                                          0.055 ║
║ Worst                                         0.000 ║
║ Total                                         0.004 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life E +MzB3 ╞═╣
║ Best                                          0.028 ║
║ Worst                                         0.000 ║
║ Total                                         0.001 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life E +MzB3 ╞═╣
║ Best                                          0.019 ║
║ Worst                                         0.000 ║
║ Total                                         0.004 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life Y +M3B3 ╞═╗
║ Best                                          0.931 ║
║ Worst                                         0.000 ║
║ Total                                         0.491 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life Y +M3B3 ╞═╣
║ Best                                          2.198 ║
║ Worst                                         0.000 ║
║ Total                                         0.474 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life Y +M3B3 ╞═╣
║ Best                                          1.373 ║
║ Worst                                         0.000 ║
║ Total                                         0.395 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life Y +M3B3 ╞═╣
║ Best                                          2.970 ║
║ Worst                                         0.000 ║
║ Total                                         0.459 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life Y +MzB3 ╞═╗
║ Best                                          0.912 ║
║ Worst                                         0.000 ║
║ Total                                         0.467 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life Y +MzB3 ╞═╣
║ Best                                          1.989 ║
║ Worst                                         0.000 ║
║ Total                                         0.321 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life Y +MzB3 ╞═╣
║ Best                                          1.407 ║
║ Worst                                         0.000 ║
║ Total                                         0.300 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life Y +MzB3 ╞═╣
║ Best                                          2.256 ║
║ Worst                                         0.000 ║
║ Total                                         0.436 ║
╚═════════════════════════════════════════════════════╝

Copy link

github-actions bot commented Jul 30, 2025

Target Mode Toolchain Environment Link
eravm E+M3B3_0.4 ir-llvm zk_evm Results
eravm E+M3B3_0.5 ir-llvm zk_evm Results
eravm E+M3B3_0.6 ir-llvm zk_evm Results
eravm E+M3B3_0.7 ir-llvm zk_evm Results
eravm E+M3B3_0.8 ir-llvm zk_evm Results
eravm E+MzB3_0.4 ir-llvm zk_evm Results
eravm E+MzB3_0.5 ir-llvm zk_evm Results
eravm E+MzB3_0.6 ir-llvm zk_evm Results
eravm E+MzB3_0.7 ir-llvm zk_evm Results
eravm E+MzB3_0.8 ir-llvm zk_evm Results
eravm Y+M3B3 ir-llvm zk_evm Results
eravm Y+MzB3 ir-llvm zk_evm Results
evm E+M3B3 ir-llvm EVMInterpreter Results
evm E+MzB3 ir-llvm EVMInterpreter Results
evm Y+M3B3 ir-llvm EVMInterpreter Results
evm Y+MzB3 ir-llvm EVMInterpreter Results
evm E+_0.8 solc EVMInterpreter Results
evm Y+ solc EVMInterpreter Results

Copy link

github-actions bot commented Jul 30, 2025

📊 Excel Report Available

Benchmarks measured for:

  • solx candidate version: solx, LLVM-based Solidity compiler for the EVM v0.1.1, LLVM revision: v1.0.2, LLVM build: 915baaf4821eb108da79a10b79167ad67b21a47b
  • solx ToT version: solx, LLVM-based Solidity compiler for the EVM v0.1.1, LLVM revision: v1.0.2, LLVM build: d7192387c3fb7594be00716a6f56b9635d0ea4d2
  • solx latest release version: solx, LLVM-based Solidity compiler for the EVM v0.1.1, LLVM revision: v1.0.2, LLVM build: b32c5ccab280fd4219e26aceb3f60f425e907498
  • solc version: 0.8.30

➡️ Download Excel Report

@akiramenai akiramenai force-pushed the dborisenkov-jumpior branch from d4710c8 to 758e87a Compare July 30, 2025 11:50
Copy link

github-actions bot commented Jul 30, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@akiramenai akiramenai force-pushed the dborisenkov-jumpior branch 2 times, most recently from e767ea6 to 7473e2b Compare July 30, 2025 14:54
@akiramenai akiramenai force-pushed the dborisenkov-jumpior branch 3 times, most recently from 3c84ace to b1a975a Compare August 31, 2025 11:05
Copy link

codecov bot commented Aug 31, 2025

Codecov Report

❌ Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 30.07%. Comparing base (d719238) to head (915baaf).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
llvm/lib/Target/EVM/EVMTargetMachine.cpp 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #870   +/-   ##
=======================================
  Coverage   30.07%   30.07%           
=======================================
  Files        2441     2442    +1     
  Lines      807942   807946    +4     
  Branches   176474   176475    +1     
=======================================
+ Hits       242962   242984   +22     
+ Misses     522806   522795   -11     
+ Partials    42174    42167    -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@akiramenai akiramenai force-pushed the dborisenkov-jumpior branch 4 times, most recently from 0856623 to dc9c096 Compare September 5, 2025 22:09
@akiramenai akiramenai marked this pull request as ready for review September 5, 2025 22:42
@akiramenai
Copy link
Collaborator Author

regressions:

 Row | Project   | Contract                                     ...as (llvm.83c8a32) | ViaIR gas (ToT) |     Delta | Delta % vs ToT
-----+-----------+----------------------------------------------...------------------+-----------------+-----------+---------------
1903 | solady    | test/utils/mocks/MockMulticallable.sol:MockMu...        1,458,249 |         432,000 | 1,026,249 |        237.56%
1543 | solady    | src/accounts/ERC6551Proxy.sol:ERC6551Proxy   ...           80,874 |          42,970 |    37,904 |         88.21%
 791 | forge-std | test/StdCheats.t.sol:StdCheatsMock           ...      208,015,889 |     208,015,636 |       253 |          0.00%
 792 | forge-std | test/StdCheats.t.sol:StdCheatsMock           ...      208,015,266 |     208,015,014 |       252 |          0.00%
1840 | solady    | test/utils/mocks/MockERC6551.sol:MockERC6551 ...          131,944 |         131,842 |       102 |          0.08%
  49 | aave-v3   | src/contracts/extensions/stata-token/StataTok...          225,764 |         225,722 |        42 |          0.02%
1665 | solady    | test/LibCWIA.t.sol:LibCWIATest               ...       32,381,613 |      32,381,602 |        11 |          0.00%
1054 | lens-core | contracts/misc/LensHubInitializable.sol:LensH...          280,931 |         280,923 |         8 |          0.00%
  56 | aave-v3   | src/contracts/extensions/stata-token/StataTok...           28,971 |          28,967 |         4 |          0.01%
1011 | lens-core | contracts/misc/LensHubInitializable.sol:LensH...          280,906 |         280,903 |         3 |          0.00%

Rerunning to exclude randomness

Copy link
Contributor

@PavelKopyl PavelKopyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The patch introduces a few SelectionDAG patterns to improve codegen for the
`br (brcond (setcc))` case. Additionally, due to the late expansion of
JUMP_UNLESS, the patch introduces a peephole pass that optimizes JUMPI
predicates:

* `ISZERO ISZERO` is folded to nothing
* `EQ ISZERO` is folded to `SUB`
* `SUB ISZERO` is folded to `EQ`
* `ISZERO ISZERO OR* PseudoJUMPI` -> `OR* PseudoJUMPI`
* `EQ ISZERO OR* PseudoJUMPI` -> `SUB OR* PseudoJUMPI`
* `SUB ISZERO OR* PseudoJUMPI` -> `EQ OR* PseudoJUMPI`
@akiramenai akiramenai merged commit 19eef91 into main Sep 8, 2025
36 checks passed
@akiramenai akiramenai deleted the dborisenkov-jumpior branch September 8, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants